package cn.demengsite.controller;

import cn.demengsite.model.BaseInfo;
import cn.demengsite.model.DTO.CashDTO;
import cn.demengsite.service.OrderService;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.logging.Logger;

@Controller
public class CashController {
    protected   final Logger logger = Logger.getLogger(CashController.class.getName());

    @Autowired
    private OrderService orderService;

    @GetMapping("/cash/showCashPage")
    public String showCashPage(){
        logger.info("come in cashPage");
        return "cash";
    }

    @PostMapping(value = "/cash/submitCash")
    @ResponseBody
    public String submitCash(@RequestBody CashDTO cashDTO){
        //存数据到order表

       BaseInfo baseInfo = orderService.submitCash(cashDTO);




        return JSON.toJSONString(baseInfo);
    }

}
